import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  AfterLoad
} from "typeorm"

import moment from "moment/moment"

moment.locale('zh-cn')

@Entity()
export class Video {
  @PrimaryGeneratedColumn()
  id: number // 视频id

  @Column({ comment: "视频地址" })
  videoUrl: string // 视频地址

  @CreateDateColumn()
  createdAt: Date | string; // 文章发布时间

  @UpdateDateColumn()
  updatedAt: Date | string; // 文章更新时间

  @AfterLoad()
  formatDate() {
    this.createdAt = moment(this.createdAt).format('LL')
    this.updatedAt = moment(this.updatedAt).format('LL')
  }
}